package com.example.demo;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;

/**
 * 
 * <p>
 * 功能描述：
 * </p>
 * 
 * @author lixh
 * @date 2019年2月12日 下午4:24:42
 * @version 1.0
 */

@RestController
@SpringBootApplication
public class HelloWordController {

	/**
	 * 
	 * 方法描述: 图表数据来源--fake
	 * 
	 * @return
	 * @author lixh
	 */
	@RequestMapping("/data")
	@ResponseBody
	public String data() {
		JSONObject object = new JSONObject();
		Map<String, Object> map = new HashMap<String, Object>();
		// 检修统计 月份
		String[] datas = { "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月" };
		String[] num = { "2", "4", "7", "23", "25", "76", "135", "162", "32", "20", "6", "2" };
		List<String> list1 = Arrays.asList(datas);
		List<String> list2 = Arrays.asList(num);
		map.put("data", list1);
		map.put("num", list2);
		String jsonString = object.toJSONString(map);
		System.out.println(jsonString);
		return jsonString;
	}
	
	@RequestMapping("/editcontent")
	public String EditContent(HttpServletRequest request, HttpServletResponse response) {
		JSONObject object = new JSONObject();
		String Content = request.getParameter("content");
		if (StringUtils.isEmpty(Content)) {
			object.put("code", "404");
			return object.toJSONString();
		}
		System.out.println("内容：" + Content);
		object.put("code", "200");
		return object.toJSONString();
	}

}
